/**
 * @Author       : cxh
 * @Date         : 2021-12-28 22:46:53
 * @LastEditTime : 2021-12-29 22:44:24
 * @LastEditors  : cxh
 * @Description  : 加密
 * @FilePath     : \vue_WorkSpace\vue-wpt\src\utils\safe.js
 */
import NodeRSA from 'node-rsa'

export const jm = (str) => {
    const publicKey = localStorage.getItem("public_key");
    const pubKey = new NodeRSA(publicKey, "pkcs8-public");
    return pubKey.encrypt(str, 'base64','utf-8').toString();

}
export const jmobj = (obj) => {
    const res = {}
    for (const i in obj) {
        if (Object.hasOwnProperty.call(obj, i)) {
            const elem = obj[i];
            res[i] = jm(elem)
        }
    }
    return res;
}